
#include <stdio.h>
#include <iostream>
#include "Spot.h"
#include "Global.h"

using std::cout; using std::endl;

//显示场景名称
void CSpot::ShowName()
{
#ifdef _WIN32
	SetConsoleTextAttribute( hConsoleHandle, SPOT_NAME_COLOR|0 );
	cout << szName;
#else
    printf(SPOT_NAME_STRING, szName);
#endif
}

/* 关于场景的详细信息 */
void CSpot::ShowDetail()
{
	//show specified spot description
	ShowName();
	cout <<endl;

#ifdef _WIN32
	SetConsoleTextAttribute( hConsoleHandle, DESCRIPTION_COLOR|0 );
	cout << szDetail << endl;
#else
    printf(DESCRIPTION_STRING, szDetail);
    cout << endl;
#endif

	// short i;
	//show those npcs in the spot
	// if ( pSpots[nSpotIndex].nNpcNum )
	// {
	// 	cout << "这里的人物有：";
	// 	for (  i = 0; i < pSpots[ nSpotIndex ].nNpcNum  ; ++ i)
	// 	{
	// 		ShowNpcName( pSpots[nSpotIndex].nNpcs[i]  );
	// 		cout << "\t";		
	// 	}
	// 	cout << endl;
	// }	

	// show the goods of the spot
	// if ( pSpots[nSpotIndex].nGoodsNum )
	// {
	// 	cout << "这里有些可以拣取的东西：";
	// 	for ( i =0; i < pSpots[nSpotIndex].nGoodsNum; ++ i)
	// 	{
	// 		ShowGoodsName( pSpots[nSpotIndex].nGoods[i] );
	// 		cout << "\t";
	// 	}
	// 	cout << endl;
	// }
	
	//show the exits of the spot
	// if( pSpots[nSpotIndex].nExitNum )
	// {
	// 	cout << "这里可以通往：";
	// 	for ( i = 0; i < pSpots[ nSpotIndex ].nExitNum ; ++ i)
	// 	{
	// 		ShowSpotName( pSpots[nSpotIndex].nExits[i] );
	// 		cout << " ";
	// 	}
	// 	cout << endl;
	// }

	//RunScripts( pSpots[nSpotIndex].nEnterScript );
}

/* 读入场景数据 */
bool CSpot::Load(CTextParser &file)
{
    short i;

	//read data one by one
    file.FindRecordHead();
    file.GotoNextLine();
    file.ReadString(szName  );
    file.GotoNextLine();
    file.ReadString(szDetail );
		
    //exits data
    file.GotoNextLine();
    file.ReadInteger( &nExitNum);	
    file.GotoNextLine();
    for ( i = 0; i < nExitNum; ++i )
        file.ReadInteger( & nExits[i] );

    //goods data
    file.GotoNextLine();
    file.ReadInteger( & nGoodsNum );
    file.GotoNextLine();
    for( i = 0; i <nGoodsNum; ++ i)
        file.ReadInteger( & nGoods[i] );

    //npcs data
    file.GotoNextLine();
    file.ReadInteger( & nNpcNum );
    file.GotoNextLine();
    for( i= 0; i <nNpcNum; ++i )
        file.ReadInteger( & nNpcs[i] );

    //enter script and leave script
    file.GotoNextLine();
    file.ReadInteger( &nEnterScript );
    file.ReadInteger( &nLeaveScript );
    return true;
}

